﻿@namespace SageKing.Studio.Pages.SageKingMessage.component

@implements IAddEdit<SysSageKingMessage,long>

@inject SysSageKingMessageService dataService
@inject SysDictTypeService selectService

<Form @ref="form"
      Model="@model" ValidateMode="FormValidateMode.Complex"
      ValidateOnChange="true"
      LabelColSpan="8" WrapperColSpan="16">

    <Row Gutter="24">
        <Col Span="12">
        <FormItem Label="名称">
            <Input ShowCount MaxLength="64" @bind-Value="@context.Name" />
        </FormItem>
        </Col>
        <Col Span="12">
        <FormItem Label="类型">
            <Select @bind-Value="@context.Type"
                    DataSource="@SelectType.Children"
                    LabelName="@nameof(SysDictData.CodeValue)"
                    ValueName="@nameof(SysDictData.ValueInt)"
                    Style="width: 100%;"
                    TItemValue="int"
                    TItem="SysDictData"
                    Placeholder="请选消息类型"
                    DefaultActiveFirstOption="true"
                    EnableSearch>
            </Select>
        </FormItem>
        </Col>
    </Row>
    <Row Gutter="24">
        <Col Span="12">
        <FormItem Label="是否启用" LabelColSpan="6" WrapperColSpan="6" WrapperColOffset="4">
            <Switch @bind-Value="@context.Status" CheckedChildren="开" UnCheckedChildren="关"></Switch>
        </FormItem>
        </Col>
    </Row>
    <Row Gutter="24">
        <Col Span="24">
        <FormItem Label="描述信息" LabelColSpan="4" WrapperColSpan="20">
            <TextArea ShowCount MaxLength="200" Width="100%" Placeholder="描述信息" @bind-Value="@context.Description"></TextArea>
        </FormItem>
        </Col>
    </Row>
</Form>

@code {

    #region IAddEdit
    public IAddEdit<SysSageKingMessage, long> Me { get { return this; } }

    public bool IsVersionValidation { get; set; } = true;

    [Parameter]
    public string Title { get; set; }

    [Parameter]
    public SysSageKingMessage model { get; set; }

    public IBaseService<SysSageKingMessage, long> DataService
    { get { return dataService; } }

    public AntDesign.Form<SysSageKingMessage> form { get; set; }
    #endregion

    //select data
    SysDictType SelectType;

    public Action<SysSageKingMessage,ChangedEnum> OnModelChanged{ get; set; }

    protected override async Task OnInitializedAsync()
    {
        SelectType = await selectService.GetDetailCache(SysDictTypeConst.code_message_type);
    }

}